package day01;

import javax.sound.midi.Soundbank;
import java.io.IOException;
import java.net.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class DataGramSocketClient01 {
    public static void main(String[] args) throws IOException {
        DatagramSocket datagramSocket = new DatagramSocket();
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入你要发送的数据：");
        String line = sc.nextLine();
        //创建数据包对象，指定发送的目的地址
        DatagramPacket packet = new DatagramPacket(
                line.getBytes(),0,line.getBytes().length,
                InetAddress.getLocalHost(),8090);
        datagramSocket.send(packet);
        datagramSocket.close();
    }
}
